﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StrategyMode.Discount
{
    /// <summary>
    /// 折扣策略上下文
    /// </summary>
    class DiscountContext
    {
        DiscountBase discountBase = null;
        internal DiscountContext(DiscountType type)
        {
            switch(type)
            {
                case DiscountType.Normal:
                    discountBase = new DiscountNormal();
                    break;
                case DiscountType.Rebate:
                    discountBase = new DiscountRebate(0.9d);
                    break;
                case DiscountType.Return:
                    discountBase = new DiscountReturn(100, 30);
                    break;
            }
        }

        /// <summary>
        /// 获取最终的结果
        /// </summary>
        /// <param name="money"></param>
        /// <returns></returns>
        internal double GetResult(double money)
        {
            if (discountBase == null)
                return 0d;
            return discountBase.GetResult(money);
        }
    }
}
